﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Able.Api.Tests
{
    [TestClass]
    public class Linq两个数组是否包含
    {
        [TestMethod]
        public void Test()
        {
            //只要 sArr与arr取交集，然后结果的长度=arr的长度就是说明sArr包含arr
            String[] sArr = { "1", "2", "3", "4" };
            String[] arr = { "2", "3", "4", "5" };

            var list = sArr.Intersect(arr);

            Console.WriteLine("公共部分");
            foreach (var i in list)
            {
                Console.WriteLine(i);
            }

            Console.WriteLine();
            Console.WriteLine("sArr比arr多的部分");
            list = sArr.Except(arr);
            foreach (var i in list)
            {
                Console.WriteLine(i);
            }


            //Console.WriteLine(list.Count() == arr.Length);
            //Assert.IsTrue(sArr.Intersect(arr).Count() == arr.Length);
        }
    }
}
